package cn.touna.jss.modules.third.tencent.enums;

import org.apache.commons.lang.StringUtils;

/**
 ********************************************************
 * 车辆识别字段枚举类
 * @author zhangjialian
 * @Date 2018-08-10 10:00
 * @Version V1.0
 ********************************************************/
public enum OcrErrorEnum {
    ERROR_REQUEST("3", "错误的请求；其中 message:account abnormal,errorno is:2 为账号欠费停服"),
    SIGN_NULL("4", "签名为空"),
    SIGN_ERROR("5", "签名串错误"),
    APPID_AND_TARGET_NOT_MATCH("6", "签名中的appid/bucket与操作目标不匹配"),
    SIGN_EXPIRE("9", "签名过期"),
    APPID_NOT_EXIST("10", "appid不存在"),
    SECRETID_NOT_EXIST("11", "secretid不存在"),
    APPID_AND_SECRETID_NOT_MATCH("12", "appid和secretid不匹配"),
    PRPLAY_ATTACK("13", "重放攻击"),
    SIGN_FAILED("14", "签名校验失败"),
    TOO_fREQUENT("15", "操作太频繁，触发频控"),
    BUCKET_NOT_EXIST("16", "Bucket不存在"),
    PARAM_UNVALID("21", "无效参数"),
    BODY_TOO_BIG("23", "请求包体过大"),
    NOT_AUTH("24", "没有权限"),
    RESOURCE_USE_UP("25", "您购买的资源已用完"),
    AUTH_INTERNAL_SERVICE_ERROR("107", "鉴权服务内部错误"),
    INTERNAL_SERVICE_OFF("108", "鉴权服务不可用"),
    INTERNAL_SERVICE_ERROR("213", "内部错误"),
    PIC_DECODE_FAILED("-1102", "图片解码失败"),
    PIC_NULL("-1300", "图片为空"),
    ISSUEDATE("-1301", "参数为空"),
    PARAMS_TOO_LONG("-1304", "参数过长"),
    PIC_DOWNLOAD_FAILED("-1308", "图片下载失败"),
    REQ_TYPE_FAILED("-9001", "请求type错误，不是 0,1"),
    IDENTIFY_FAILED("-9002", "识别失败"),
    PIC_UNVAILD("-9005", "图片无效"),
    PREPROCESS_FAILED("-9006", "预处理失败");

    OcrErrorEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public static OcrErrorEnum getNameByCode(String code){
        if(StringUtils.isEmpty(code)){return null;}
        for(OcrErrorEnum ocr: OcrErrorEnum.values()){
            if (ocr.getCode().equals(code)){
                return ocr;
            }
        }
        return null;
    }

    private String code;
    private String name;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}

